﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.GenerateDebtorCode" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
using System.Text;
namespace SIPO.Web.AjaxHandler.Loaddata
{
    public class GenerateDebtorCode : SIPO.Web.BaseHandler
    {

        private recDebtorRepo recDebtorDal = new recDebtorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);

        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            bool IsPerson = Convert.ToBoolean(context.Request.Params["IsPerson"]);
            int hasil = 0;
            // bool IsPerson = Convert.ToBoolean( jo["IsPerson"]);
            hasil = recDebtorDal.generatecode(IsPerson);

            StringBuilder sbProject = new StringBuilder();

            sbProject.Append("{");
            sbProject.AppendFormat("{0}Code{0}:{0}{1}{0}","\"", hasil);
            sbProject.Append("}");
            
            context.Response.Write(sbProject.ToString()); ;
        }


        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}